fmdmeta_prop.validators = {};

fmdmeta_prop.validators["NotEmpty"] = 
{
	"func" : "(v){"+
					"return v!=null && ''!=$.trim(v);"+
				  "}",
	"zh" : "不能为空",
	"en" : "Empty is not allowed"
};

fmdmeta_prop.validators["ValidAplhaNumeric"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;var regu = '^[0-9a-zA-Z]+$';var re = new RegExp(regu);if (re.test(v)) {return true;}else{return false;}"+
				  "}",
	"zh" : "只能为字母和数字",
	"en" : "Only english charactors and numbers are allowed"
};

fmdmeta_prop.validators["ValidAplhaNumericUnderline"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;var regu = '^[0-9a-zA-Z\_]+$';var re = new RegExp(regu);if (re.test(v)) {return true;}else{return false;}"+
				  "}",
	"zh" : "只能为字母、数字和下划线",
	"en" : "Only english charactors, numbers and underline are allowed"
};

fmdmeta_prop.validators["ValidCurrency"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;var regu = '^[0-9]+[\.][0-9]{0,2}$';var re = new RegExp(regu);if (re.test(v)) {return true;}else {return false;}"+
				  "}",
	"zh" : "不是有效金额",
	"en" : "Not valid currency"
};

fmdmeta_prop.validators["ValidDate"] = 
{
	"func" : "(v){"+
		"if (v==null || ''==$.trim(v)) return true;\n" +
	    'var fmt = "yyyy-MM-dd";\n'+
	    'var yIndex = fmt.indexOf("yyyy");\n'+
	    'if (yIndex ==- 1) {\n'+
	        'return false;\n'+
	    '}\n'+
	    'var year = v.substring(yIndex, yIndex + 4);\n'+
	    'var mIndex = fmt.indexOf("MM");\n'+
	    'if (mIndex ==- 1) {\n'+
	        'return false;\n'+
	    '}\n'+
	    'var month = v.substring(mIndex, mIndex + 2);\n'+
	    'var dIndex = fmt.indexOf("dd");\n'+
	    'if (dIndex ==- 1) {\n'+
	        'return false;\n'+
	    '}\n'+
	    'var day = v.substring(dIndex, dIndex + 2);\n'+
	    'if (isNaN(year) || year > "2100" || year < "1900") {\n'+
	        'return false;\n'+
	    '}\n'+
	    'if (isNaN(month) || month > "12" || month < "01") {\n'+
	        'return false;\n'+
	    '}\n'+
	    'var maxday = 31;\n'+
	    'if (month == 4 || month == 6 || month == 9 || month == 11) {\n'+
	    	'maxday = 30;\n'+
	    '}\n'+
	    'if (month == 2) {\n'+
	        'if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {\n'+
	        	'maxday = 29;\n'+
	        '}\n'+
	        'else {\n'+
	        	'maxday = 28;\n'+
	        '}\n'+
	    '}\n'+
	    'if (day > maxday || day < "01") {\n'+
	        'return false;\n'+
	    '}\n'+
	    'return true;\n'+
		"}",
	"zh" : "不是有效日期 (yyyy-MM-dd)",
	"en" : "Not valid date (yyyy-MM-dd)"
};

fmdmeta_prop.validators["ValidDatetimeMM"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;\n"+
					"var regu=/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\d):[0-5]?\d$/;"+
					"return regu.test(v);\n"+
				  "}",
	"zh" : "不是有效日期时间格式 (yyyy-MM-dd hh:mm)",
	"en" : "Not validate date and time (yyyy-MM-dd hh:mm)"
};

fmdmeta_prop.validators["ValidDatetimeSS"] = 
{
	"func" : "(v){"+
	                "if (v==null || ''==$.trim(v)) return true;\n"+
					"var regu=/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$/;"+
					"return regu.test(v);\n"+
				  "}",
	"zh" : "不是有效日期时间格式 (yyyy-MM-dd hh:mm:ss)",
	"en" : "Not validate date and time (yyyy-MM-dd hh:mm:ss)"
};

fmdmeta_prop.validators["ValidEmail"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;\n"+
					"var emailReg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[-|_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;\n"+
				    "return emailReg.test(v);"+
				  "}",
	"zh" : "不是有效邮箱地址",
	"en" : "Not valid email address"
};

fmdmeta_prop.validators["ValidAge"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;\n"+
					"var regu = /^(?:[0-9][0-9]?|1[01][0-9]|120)$/;return regu.test(v);"+
				  "}",
	"zh" : "不是有效年龄",
	"en" : "Not valid age"
};

fmdmeta_prop.validators["ValidIdCard"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;\n"+
					"var regu = /^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/;return regu.test(v);"+
				  "}",
	"zh" : "不是有效身份证号",
	"en" : "Not valid IdCard"
};

fmdmeta_prop.validators["ValidInteger"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;\n"+
					"var regu = /^[-]{0,1}[0-9]{1,}$/;return regu.test(v);"+
				  "}",
	"zh" : "不是有效整数",
	"en" : "Not valid integer"
};

fmdmeta_prop.validators["ValidPositiveInteger"] = 
{
	"func" : "(v){"+
				   "if (v==null || ''==$.trim(v)) return true;\n"+
					"var regu = /^[1-9]*[1-9][0-9]*$/;return regu.test(v);"+
				  "}",
	"zh" : "不是有效正整数",
	"en" : "Not valid positive integer"
};

fmdmeta_prop.validators["ValidNonNegativeinteger"] = 
{
	"func" : "(v){"+
				   "if (v==null || ''==$.trim(v)) return true;\n"+
					"var regu = /(^[0-9]+\d*$)|(^0$)/;return regu.test(v);"+
				  "}",
	"zh" : "不是有效非负整数",
	"en" : "Not valid Non Negative integer"
};

fmdmeta_prop.validators["ValidIPv4"] = 
{
	"func" : "(v){"+
	        "if (v==null || ''==$.trim(v)) return true;\n"+
		    "var re = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;\n"+
		    /*"if (re.test(v)) {\nalert(RegExp.$1);"+
		        "if ( RegExp.$1 < 256 && RegExp.$1>=0 && RegExp.$2 < 256 && RegExp.$2>=0 && RegExp.$3 < 256 && RegExp.$3>=0 && RegExp.$4 < 256 && RegExp.$4>=0) {\n"+
		            "alert(2);return true;\n"+
		        "}\n"+
		    "}\n"+*/
		    "return re.test(v);\n"+
				  "}",
	"zh" : "不是有效IP(v4)地址",
	"en" : "Not valid IP(v4) address"
};

fmdmeta_prop.validators["ValidNumeric"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;return !isNaN(v);"+
				  "}",
	"zh" : "不是有效数字",
	"en" : "Not a valid number"
};

fmdmeta_prop.validators["ValidTime"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;var regu=/([01]\d|2[0-3]):([0-5][0-9]):([0-5][0-9])/;"+
					"return regu.test(v);"+
				  "}",
	"zh" : "不是有效时间格式(hh:mm:ss)",
	"en" : "Not a valid time format(hh:mm:ss)"
};

fmdmeta_prop.validators["ValidTimeNoSS"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;var regu=/([01]\d|2[0-3]):([0-5][0-9])/;"+
					"return regu.test(v);"+
				  "}",
	"zh" : "不是有效时间格式(hh:mm)",
	"en" : "Not a valid time format(hh:mm)"
};

fmdmeta_prop.validators["ValidCnMobile"] = 
{
	"func" : "(v){"+
					"if (v==null || ''==$.trim(v)) return true;var regu = /^[1][3,5,7,8][0-9]{9}$/;"+
				    "return regu.test(v);"+
				  "}",
	"zh" : "不是有效国内手机号",
	"en" : "Not a valid chinese mobile number"
};

fmdmeta_prop.validators["ValidCnPhone"] = 
{
	"func" : "(v){"+
	                "if (v==null || ''==$.trim(v)) return true;\n"+
					"var phoneRegWithArea = /^[0][1-9]{2,3}-[0-9]{5,10}$/;"+
				    "var phoneRegNoArea = /^[1-9]{1}[0-9]{5,8}$/;"+
				    "if ( v.length > 9 ) {"+
				    "    if ( phoneRegWithArea.test(v) ) {"+
				    "        return true;"+
				    "    } else {"+
				    "        return false;"+
				    "    }"+
				    "} else {"+
				    "    if ( phoneRegNoArea.test( v ) ) {"+
				    "        return true;"+
				    "    } else {"+
				    "        return false;"+
				    "    }"+
				    "}"+
				"}",
	"zh" : "不是有效国内电话号码",
	"en" : "Not a valid chinese phone number"
};

fmdmeta_prop.validators["LengthLimit"] = 
{
	"func" : "(v, c){"+
					"if (v==null || ''==$.trim(v)) return true;return v.toString().length<=Number(c)"+
				  "}",
	"condition" : true,
	"conditionValidator" : "ValidPositiveInteger",
	"zh" : "输入的数据过长",
	"en" : "Value is too long"
};

fmdmeta_prop.validators["RegExp"] = 
{
	"func" : "(v, c){"+
					"if (v==null || ''==$.trim(v)) return true;return new RegExp(c).test(v);"+
				  "}",
	"condition" : true,
	"zh" : "不是有效格式数据",
	"en" : "Not a valid format data"
};